<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>
    <script type="text/javascript">
        $(function() {
            parent.$.messager.progress('close');
            submitForm = function( $dialog, $gird){
                $('#bn_advertisement_issue_form').form('submit',{
                    url:'${ctx}/bn/advertisement/issue/up/insert',
                    queryParams:{_m:'exec'},
                    onSubmit:function(){
                        if($(this).form('enableValidation').form('validate')){
                            return true;
                        }else{
                            return false;
                        }
                    },
                    success:function(data){
                        var json =  eval("(" +data+ ")");
                        if(statusMsg(json)){
                            parent.$.messager.alert("提示","保存成功！","info",function(){
                                $dialog.dialog('destroy');
                                $gird.datagrid('reload');
                            });
                        }
                    }
                });
            };

            var viewDialog ;
            //广告添加
            adSave = function(){
                viewDialog = parent.$.dialog({
                    title: '<i class="fa fa-th-large"></i><span class="dialog-title">&nbsp;选取广告<span>',
                    href: '${ctx}/bn/advertisement/issue/up/insert?_m=adquery&r='+Math.random(),
                    width: 800,
                    height: 500,
                    modal: true,
                    onClose : function() {
                        $(this).dialog('destroy');
                    },
                    buttons: [{
                        text:'<i class="fa fa-floppy-o" aria-hidden="true"></i>&nbsp;选 择',
                        width:'70px',
                        handler: function(){
                            var json = viewDialog.find('iframe').get(0).contentWindow.chooseAd();
                            $("#advertisementId").val(json.advertisementId);
                            $("#advertiserId").val(json.advertiserId);
                            $("#adName").val(json.adName);
                            $("#adShortName").val(json.adShortName);
                            $("#pic").val(json.pic);
                            $("#url").val(json.url);
                            $("#content").val(json.content);

                            viewDialog.dialog('destroy');
                        }
                    },{
                        text:'<i class="fa fa-reply" aria-hidden="true"></i>&nbsp;返 回',
                        width:'70px',
                        handler: function(){
                            viewDialog.dialog('destroy');
                        }
                    }]
                });
            }

            $('#isPermanent').combobox({
                onChange : function(){
                    var v = $("#isPermanent").combobox("getValue") ;
                    if(v == "2"){
                        $('#beginDate').css({"width":"180px"}).datebox({
                            required: true
                        });
                        $('#endDate').css({"width":"180px"}).datebox({
                            required: true
                        });
                        $("#date").show();
                    }else{
                        $('#beginDate').css({"width":"180px"}).datebox({
                            required: false
                        });
                        $('#endDate').css({"width":"180px"}).datebox({
                            required: false
                        });
                        //$("input[name='beginDate']").val("")
                        //$("input[name='endDate']").val("")
                        $("#date").hide();
                    }
                }
            });

            $("#date").hide();
        });
    </script>
</head>
<body>
<div class="form-box">
    <div class="form-body">
        <form method="post" role="form" name="bn_advertisement_issue_form" id="bn_advertisement_issue_form" class="easyui-form form form-horizontal" data-options="novalidate:true">
            <input type="hidden" id="advertisementId" name="advertisementId" value=""/>
            <input type="hidden" id="advertiserId" name="advertiserId" value=""/>
            <input type="hidden" id="adShortName" name="adShortName" value=""/>
            <input type="hidden" id="pic" name="pic" value=""/>
            <input type="hidden" id="url" name="url" value=""/>
            <input type="hidden" id="content" name="content" value=""/>
            <div class="seg-title">
                <div class="seg-title-box">
                    <ul>
                        <li class="seg-title-box-icon" ><img src="${ctx }/assets/images/communication.gif"/></li>
                        <li class="seg-title-box-text">基本信息</li>
                    </ul>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">广告：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-8">
                    <input type="text" id="adName" name="adName" onclick="adSave()" class="form-control easyui-validatebox" style="cursor:pointer;width:100%;height:34px;line-height:34px;" data-options="editable:false" required="required" validType="length[1,50]">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">是否永久：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="isPermanent" name="isPermanent" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="
                    valueField: 'label',
                    textField: 'value',
                    data: [{
                        label: '1',
                        value: '永久'
                    },{
                        label: '2',
                        value: '非永久'
                    }],editable:false" />
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">媒体分类：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="mediaClassify" name="mediaClassify" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="
                    valueField: 'label',
                    textField: 'value',
                    data: [{
                        label: '1',
                        value: 'app：移动应用'
                    },{
                        label: '2',
                        value: 'pc：电脑'
                    }],editable:false" />
                </div>
            </div>
            <div id="date" class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">开始日期：</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="beginDate" name="beginDate" class="form-control" style="width:100%;height:34px;line-height:34px;" data-options="editable:false"/>
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">结束日期：</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="endDate" name="endDate" class="form-control" style="width:100%;height:34px;line-height:34px;" data-options="editable:false"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">页面：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="page" name="page" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="valueField: 'code',textField: 'name',url:'${ctx}/tcode/all/method?method=getCacheCdAdvertisementPage',editable:false"/>
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">广告位：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="adPositionid" name="adPositionid" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="valueField: 'code',textField: 'name',url:'${ctx}/tcode/all/method?method=getCacheCdAdPosition',editable:false"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">广告类型：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="adType" name="adType" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="valueField: 'code',textField: 'name',url:'${ctx}/tcode/all/method?method=getCacheCdAdType',editable:false"/>
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">设备系统：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="deviceSystem" name="deviceSystem" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="
                    valueField: 'label',
                    textField: 'value',
                    data: [{
                        label: '1',
                        value: '苹果(ios)'
                    },{
                        label: '2',
                        value: '安卓(android)'
                    },{
                        label: '3',
                        value: '全部'
                    }],editable:false" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">
                    <p class="label-txt">展示方式：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="showWay" name="showWay" class="form-control easyui-combobox" style="width:100%;height:34px;line-height:34px;" required="required" data-options="
                    valueField: 'label',
                    textField: 'value',
                    data: [{
                        label: '1',
                        value: '轮播'
                    },{
                        label: '2',
                        value: '静态'
                    },{
                        label: '3',
                        value: '动态'
                    },{
                        label: '4',
                        value: '列表'
                    }],editable:false" />
                </div>
                <label class="col-sm-2 control-label">
                    <p class="label-txt">排序：</p>
                    <p class="star">*</p>
                </label>
                <div class="col-sm-3">
                    <input type="text" id="seq" name="seq" value="1"  class="form-control easyui-validatebox" style="width:100%;height:34px;line-height:34px;" required="required" validType="number">
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>